package com.dili.dd.gpi.util.spring;


import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * Created by rabbit on 14-5-25.
 */
public class MultipleDataSource extends AbstractRoutingDataSource {
    private static final ThreadLocal<DataSourceLookupKey> dataSourceKey = new InheritableThreadLocal<>();

    public static void setDataSourceKey(DataSourceLookupKey dataSource) {
        dataSourceKey.set(dataSource);
    }

    @Override
    protected String determineCurrentLookupKey() {
        return dataSourceKey.get().name();
    }
}